<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Promise对象</title>
</head>
<body>
  <script>
    const promise = new Promise((resolve, reject) => {
        if (true) {
          resolve('cs');
        } else {
          reject(Error('报错了')); // 这里最好都以Error对象返回出去 
        }
      })
    // then就是监听前面定义的promise实例
    promise.then((result) => {
      console.log('result', result);
    }).catch((err) => {
      console.log('err', err);
    });
  </script>
</body>
</html>